package com.wx.arrays_;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/7/21 - 17:03
 */
public class ArraysMethod01 {
    public static void main(String[] args) {
//        Integer[] integers = {1, 20, 90};
//        System.out.println(Arrays.toString(integers));
        int[] arr = {-1, 1, 7, 6, 89};
/*        Arrays.sort(arr, new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Integer i1 = (Integer) o1;
                Integer i2 = (Integer) o2;
                return i1 - i2;
            }
        });
        System.out.println("===排序后===");
        System.out.println(Arrays.toString(arr));*/
        bubble01(arr);
        System.out.println(Arrays.toString(arr));
        Integer[] arrs = {1, 2, 90, 123, 567};
        int index = Arrays.binarySearch(arrs, 568);
        System.out.println("index=" + index);
        Integer[] newArr = Arrays.copyOf(arrs, arrs.length);
        System.out.println(Arrays.toString(newArr));
        Integer[] num = new Integer[]{1, 2, 90, 123};
//        Arrays.fill(num, 99);
        System.out.println(Arrays.toString(num));
        Integer[] arr2 = {1, 2, 90, 123};
        System.out.println(Arrays.equals(num, arr2));

        List asList = Arrays.asList(2, 3, 4, 56, 1);
        System.out.println(asList);
        System.out.println(asList.getClass());
    }

    public static void bubble01(int[] arr) {
        int temp = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] < arr[j + 1]) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
